package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ArticleService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Xiao
 * @version 1.0
 * @description
 * @date 2021/11/23
 */
@RestController
public class ArticleClient implements IArticleClient {
    @Autowired
    private ArticleService articleService;
    /**
     * 保存文章
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/api/v1/article/feign/save")
    public ResponseResult saveArticle(@RequestBody ArticleDto dto) {
        return articleService.saveArticle(dto);
    }

    /**
     * 自媒体端上架/下架/删除文章时，同步修改app端文章
     * @param articleConfig
     */
    @Override
    @PostMapping("/api/v1/article/feign/update")
    public ResponseResult delOrDownArticle(@RequestBody ApArticleConfig articleConfig) {
        return articleService.delOrDownArticle(articleConfig);
    }
}
